package com.dream.myqiyi.service.impl;

import java.sql.SQLException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.dream.myqiyi.dao.NoteTagsModel;
import com.dream.myqiyi.service.NoteTagsManager;
import com.j256.ormlite.dao.Dao;

public class NoteTagsManagerImpl extends GenericManagerImpl<NoteTagsModel, Integer> implements NoteTagsManager{
	Dao<NoteTagsModel, Integer> noteTagsDao;
	
	public NoteTagsManagerImpl(Dao<NoteTagsModel, Integer> noteTagsDao) {
        super(noteTagsDao);
        this.noteTagsDao = noteTagsDao;
    }
	
	public List<NoteTagsModel> findByNoteGuid(String guid) {
		Map<String, Object> filedValues = new HashMap<String, Object>(); 
		filedValues.put("noteGuid", guid);
		try {
			return noteTagsDao.queryForFieldValues(filedValues);
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return null;	
	}
	
	public List<NoteTagsModel> findByTagGuid(String guid) {
		Map<String, Object> filedValues = new HashMap<String, Object>(); 
		filedValues.put("tagGuid", guid);
		try {
			return noteTagsDao.queryForFieldValues(filedValues);
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return null;	
		
	}
	public void removeByNoteGuid(String noteGuid) {
		List<NoteTagsModel> noteTagsList = findByNoteGuid(noteGuid);
		try {
			noteTagsDao.delete(noteTagsList);
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}
